package com.graduation.controller;

import com.graduation.entity.Shop;
import com.graduation.service.ShopService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class ShopController {

    @Resource
    private ShopService shopService;
    /**
     * 开设新店铺
     * @param shop
     * @return
     */
    @PostMapping("/regNewShop.do")
    public String openShop(Shop shop){
        Integer response = shopService.openStore(shop);
        if(response == 1){
            return "index";
        }
       return "checkout";
    }

    /**
     * 发起异步请求将以填写数据返回json到前端
     * @return
     */
    @GetMapping("/findShopBaseInfo.do")
    @ResponseBody
    public Shop findShopMsg(String email){
        Shop shopMsg = shopService.findShopMsg(email);
        return shopMsg;
    }
}
